﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Face8280WebSocketServer.Utility.Extend
{
    public static class JobjectExtend
    {
        /// <summary>
        /// json字符串转JObject
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static JObject ToJObject(this string entity)
        {
            try
            {
                return JObject.Parse(entity);
            }
            catch
            {
                return default(JObject);
            }
        }
        /// <summary>
        /// json字符串转JArray
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static JArray ToJArray(this string entity)
        {
            try
            {
                return JArray.Parse(entity);
            }
            catch
            {
                return default(JArray);
            }
        }

    }
}
